package teacher.action.student;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

import teacher.bean.Award;
import teacher.bean.Students;
import teacher.bean.Teacher;
import teacher.service.award;
import teacher.service.student;
import tools.StringDate;

public class addStu {

	private static final long serialVersionUID = 1L;
	private Students stu = new Students();
	private String dates;
	String suc;	
	
	public Students getStu() {
		return stu;
	}

	public void setStu(Students stu) {
		this.stu = stu;
	}

	public String getDates() {
		return dates;
	}

	public void setDates(String dates) {
		this.dates = dates;
	}

	public String getSuc() {
		return suc;
	}

	public void setSuc(String suc) {
		this.suc = suc;
	}

	public String execute() throws Exception {

		HttpServletRequest request=ServletActionContext.getRequest();
		Teacher tea=(Teacher)request.getSession().getAttribute("teacher");
		int teaId=tea.getTeaId();
		stu.setTeaId(teaId);
		
		if(dates!=null&&dates.length()>0)
		{
			stu.setLeaveDate(new StringDate().StringToDate(dates));
		}
		else
		{
			stu.setLeaveDate(new Date());
		}
		/*System.out.println(stu.getName()+"aaa");
		System.out.println(stu.getSex());
		System.out.println(stu.getLeaveDate());
		System.out.println(stu.getDegreePaper());
		System.out.println(stu.getDegree());*/
		if(new student().insertStu(stu)) {
			this.setSuc("success");
			return "success";		
		} else {
			return "error";
		}
	}

}
